<template>
	<view>
		<scroll-view scroll-y="true" :style="{height: scrollHeight}">
			<view class="mt-5" v-if="u_loadmore">
				<u-loadmore status="loading" icon-type="circle" />
			</view>
		<!-- 商品分类 -->
			<view class="" v-else></view>
		</scroll-view>
		
		<view class="seach">
			<u-navbar :is-back="false" :border-bottom="false" :background="background">
				<view class="d-flex a-center j-sb w-100">
					<view class="span-5 pl-2 py-2"  @click="backtrack_img">
						<u-icon name="arrow-left" color="#ffffff" size="40"></u-icon>
					</view>
					<view class="font-lg font-weight text-white">添加业务员</view>
					<view class="span-5"></view>
				</view>
			</u-navbar>
		</view>
		
		
		
		<view class="">
			<view class="m-2 px-3 bg-white rounded-10">
				<view class="py-3 d-flex j-sb border-bottom">
					<view class="font-weight font-35">姓名<text class="text-red">*</text></view>
					<view class="">
						<input type="text" v-model="user_name" @input="name_input" value="" class="text-right" placeholder="请输入姓名" />
					</view>
				</view>
				<view class="py-3 d-flex j-sb border-bottom">
					<view class="font-weight font-35">手机</view>
					<view class="">
						<input type="text" v-model="user_mobile" @input="mobile_input" value="" class="text-right" placeholder="请输入手机号" />
					</view>
				</view>
				<view class="py-3 d-flex j-sb">
					<view class="font-weight font-35">停用帐号</view>
					<view class="">
						<u-switch v-model="is_show" size="43" @change="toggle"></u-switch>
					</view>
				</view>
			</view>
		</view>	
			
		<view class="footer"></view>
		<view class="position-fixed bottom-0 w-100 bg-white py">
			<view class="d-flex sub j-sb p-2">
				<button type="warn" class="dele" @click="save">保存</button>
				<button type="warn" class="rele" @click="backtrack_img">取消</button>
			</view>	
		</view>
		<u-toast ref="uToast"/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scrollHeight:0, // 自适应高度
				u_loadmore:true, // 加载中
				user_name: "",
				user_mobile: "",
				is_show: "",
				background: {
					background: '#fa7226',
					backgroundSize: 'cover',
				},
			}
		},
		onReady() {
			let _this=this
			
		},
		methods: {
			// 姓名
			name_input(e){
				this.user_name=e.detail.value
			},
			
			// 手机号
			mobile_input(e){
				this.user_mobile=e.detail.value
			},
			
			// 是否停用
			toggle(e){
				if(e){
					this.is_show=1
				}else{
					this.is_show=0
				}
			},
			
			
			showToast(e) {
				this.$refs.uToast.show({
					title: e,
					type: 'default',
				})
			},
			
			
			save(){
				if(this.user_name==''){
					this.showToast('请输入姓名')
				}else if(this.user_mobile==''){
					this.showToast('请输入手机号')
				}else{
					
					this.$H.post("admin/merchant/yewu/add", {
					  user_name:this.user_name, // 姓名
					  user_mobile:this.user_mobile, // 手机
					  is_show:this.is_show, // 是否禁用
					}).then(res => {
					  console.log(res)
					  if(res.status.succeed==0){
					  	this.$refs.uToast.show({
					  		title: res.status.error_desc,
					  		type: 'default',
					  	})
					  	uni.hideLoading()
					  }else{
					  	uni.navigateTo({
					  		url:'/pagesB/yewu/list'
					  	})
					  	uni.hideLoading()
					  }
					
					})
					
					
					
				}
			},
			
			
			// 返回
			backtrack_img(){
				uni.navigateBack({
					delta:1
				})
			},
		},
		onLoad() {
			// 商品分类 merchant merchant
			// this.$H.post("admin/merchant/goods/merchant/category").then(res=>{
			// 	if(res.status.succeed == 1){
			// 		this.u_loadmore=false   
			// 		this.goodsClazz=res.data
			// 		this.goodsClazz.filter((item,index)=>{
			// 				return item.icon_show=false,item.iconshow=false,item.show=false
			// 		})
			// 		this.oneGoods=this.goodsClazz.filter((item,index)=>{
			// 			if(item.parent_id==0){
			// 				this.oneGoods=this.goodsClazz.forEach((v,i)=>{
			// 					if(item.cat_id==v.parent_id){
			// 						return item.iconshow=true
			// 					}
			// 				})
			// 				return item
			// 			}
			// 		})
			// 	}
			// })	
			
			this.u_loadmore=false 
		},
		onShow() {
			var globalData = getApp().globalData.closeLists; //获取全局变量
			getApp().globalData.closeLists= ''; //修改全局变量
			// 商品分类
			
		},
		
	}
</script>

<style>
	.tab_title{
		border: 1px solid #E7484D;
		color: #E7484D;
		border-radius: 40upx;
		overflow: hidden;
	}
	.active_class{
		background-color: #E7484D;
		color: #FFFFFF;
	}
	.sub /deep/ .dele{
		background: linear-gradient(to right,#ff9900,#ff9900);
		border-radius: 50upx;
		width: 45%;
		color: #FFFFFF;
		font-size: 30upx;
	}
	.sub /deep/ .dele::after{
		border: none;
		color: #000000;
	}
	.sub /deep/ .rele{
		width: 45%;
		border-radius: 50upx;
		font-size: 30upx;
		background: linear-gradient(to right,#F31E3E,#FB4F37);
	}
	.footer{
		height: 134upx;
	}
</style>